using TSharp.Core;
using TSharp.Core.Repository;
[assembly: TSharp.Core.Osgi.RegLazyLoading(typeof(ISpecificationLocator), typeof(SpecificationLocatorStub), TSharp.Core.Osgi.LoadingPriority.Lowest)]
namespace TSharp.Core.Repository
{
    /// <summary>
    /// 
    /// </summary>
    /// <author>
    /// tangjingbo
    /// </author>
    /// <remarks>
    /// tangj15 at 2012-3-16 9:59
    /// </remarks>
    public class SpecificationLocatorStub : ISpecificationLocator
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="SpecificationLocatorStub"/> class.
        /// </summary>
        public SpecificationLocatorStub()
        {
        }

        /// <summary>
        /// Gets requested specification for given entity.
        /// </summary>
        /// <typeparam name="TSpecification"></typeparam>
        /// <typeparam name="TEntity"></typeparam>
        /// <returns></returns>
        public TSpecification Resolve<TSpecification, TEntity>()
            where TSpecification : ISpecification<TEntity>
            where TEntity : class
        {
            return AopContext.Services.GetRequest().Get<TSpecification>();
        }
    }
}